package com.example.controller;

import com.example.model.WxbCustomer;
import com.example.model.WxbGood;
import com.example.service.GoodService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;


@Controller
@RequestMapping("/cust")
public class CustController {

    @Autowired
    private GoodService goodService;

    @RequestMapping("/goods-add")
    public String goodsAdd(Model model){
        WxbCustomer customer = (WxbCustomer) SecurityUtils.getSubject().getPrincipal();
        model.addAttribute("customer",customer);

        return "商品管理-添加商品";
    };

    @RequestMapping("/goods-list")
    public String goodsList(Model model){
        WxbCustomer customer = (WxbCustomer) SecurityUtils.getSubject().getPrincipal();

        List<WxbGood> goodList =goodService.findGoodsByCustomer(customer);
        model.addAttribute("customer",customer);
        model.addAttribute("goodList",goodList);


        return "商品信息管理";
    };


}
